<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<head>
<title>Market place</title>
</head>
<f:view>
	<body>
		<ui:composition template="/templates/adminTemplate.xhtml">
			<ui:define name="content">

				<div id="center">

					<h:form prependId="false" id="detailForm">
						<h:panelGrid columns="1">
							<h:panelGrid columns="7" style="width:100%; font-size:0.9em;">
								<p:commandButton ajax="true" value="Reload"
									update=":detailForm:salesGroupByProductTable" style="float:left"
									actionListener="#{reportController.loadSalesGroupByProduct}" />
								<h:outputText value="Required date:"></h:outputText>
								<h:outputText value="From:"></h:outputText>
								<p:calendar
									value="#{reportModel.salesGroupByProductQuery.startDate}" />
								<h:outputText value="To:"></h:outputText>
								<p:calendar value="#{reportModel.salesGroupByProductQuery.endDate}" />
								<h:outputText value="Calculate all orders exclude Canceled order"></h:outputText>
							</h:panelGrid>

							<p:dataTable id="salesGroupByProductTable" var="sales" sortBy="1"
								value="#{reportModel.salesGroupByProduct}" paginator="true"
								rows="50" filterEvent="enter"
								rowsPerPageTemplate="5,7,10,15,20,30,40,50,100,150,200,250,300,400,500"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
								<p:column headerText="id" sortBy="#{sales.productID}">
									<h:outputText value="#{sales.productID}" />
								</p:column>
								<p:column sortBy="#{sales.productName}"
									filterBy="#{sales.productName}" filterMatchMode="contains">
									<h:outputText value="#{sales.productName}" />
								</p:column>
								<p:column sortBy="#{sales.productType}"
									filterBy="#{sales.productType}" filterMatchMode="contains">
									<h:outputText value="#{sales.productType}" />
								</p:column>

								<p:column  headerText="Ordered Quantity" sortBy="#{sales.orderedQuantity}">
									<h:outputText value="#{sales.orderedQuantity}" />
								</p:column>
								<p:column headerText="Ordered Amount" sortBy="#{sales.orderedAmount}">
									<h:outputText value="#{sales.orderedAmount}" />
								</p:column>
								<p:column  headerText="Delivered Quantity" sortBy="#{sales.deliveredQuantity}">
									<h:outputText value="#{sales.deliveredQuantity}" />
								</p:column>
								<p:column headerText="Delivered Amount" sortBy="#{sales.deliveredAmount}">
									<h:outputText value="#{sales.deliveredAmount}" />
								</p:column>
								
								<p:summaryRow>
									<p:column colspan="3" style="text-align:right">
										<h:outputText value="Total: "></h:outputText>
									</p:column>

									<p:column>
										<h:outputText
											value="#{reportModel.salesGroupByProductOrderedTotalQuantity}"></h:outputText>
									</p:column>
									<p:column>
										<h:outputText
											value="#{reportModel.salesGroupByProductOrderedTotalAmountLabel}"></h:outputText>
									</p:column>
									<p:column>
										<h:outputText
											value="#{reportModel.salesGroupByProductDeliveredTotalQuantity}"></h:outputText>
									</p:column>
									<p:column>
										<h:outputText
											value="#{reportModel.salesGroupByProductDeliveredTotalAmountLabel}"></h:outputText>
									</p:column>
									
								</p:summaryRow>
							</p:dataTable>

						</h:panelGrid>
					</h:form>

				</div>
			</ui:define>
		</ui:composition>
	</body>
</f:view>
</html>